
from collection_manage.models import UserCollection
def collect_controller(user_id,advertisement_id):
    userCollection = UserCollection()
    if (len(UserCollection.objects.filter(user_id=user_id).filter(advertisement_id=advertisement_id)) == 0):

        userCollection.user_id = user_id
        userCollection.advertisement_id = advertisement_id
        userCollection.save()
        return "collected"
    else:
        UserCollection.objects.filter(user_id=user_id).filter(advertisement_id=advertisement_id).delete()
        return "deleted"